<template>
  <div>
    <page-tab-list
      url="/SyDangerCheckTask/GetPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
    >
      <div v-if="this.active === 0">
        <van-cell class="card" v-for="(item, index) in list" :key="index">
           <van-tag
            v-if="item.Status === 10 && !item.IsExpire"
            class="info_tag"
            color="#1989fa"
            >进行中</van-tag
          >
          <van-tag
            v-if="item.Status === 10 && item.IsExpire"
            class="info_tag"
            type="danger"
            >已过期</van-tag
          >
          <div class="warn_item">
            <div @click="goDetail(item)">
              <van-row>
                <van-col span="24">
                  {{ index + 1 }}、{{ item.CheckTaskName }}</van-col
                >
              </van-row>
              <van-row gutter="20" class="dep_sort">
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />{{ item.CheckTypeName +(item.ItemTypeName?'('+item.ItemTypeName+')':'') }}</van-col
                >
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_danger.png"
                    alt=""
                  />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                    item.CheckCnt
                  }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />{{ item.CreateChnName }}
                </van-col>
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ item.StartDate | formatDate }}至{{
                    item.EndDate | formatDate
                  }}</van-col
                >
              </van-row>
            </div>
          </div>
        </van-cell>
      </div>
      <div v-if="this.active === 1">
        <van-cell v-for="(item, index) in list" :key="index" class="card">
          <van-tag v-if="item.Status == 0" class="info_tag" color="grey"
            >未开始</van-tag
          >
          <div class="warn_item">
            <div @click="goDetail(item)">
              <van-row>
                <van-col span="24">
                  {{ index + 1 }}、{{ item.CheckTaskName }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />{{ item.CheckTypeName +(item.ItemTypeName?'('+item.ItemTypeName+')':'') }}</van-col
                >
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_danger.png"
                    alt=""
                  />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                    item.CheckCnt
                  }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="12">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />{{ item.CreateChnName }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ item.StartDate | formatDate }}至{{
                    item.EndDate | formatDate
                  }}</van-col
                >
              </van-row>
            </div>
          </div>
        </van-cell>
      </div>
      <div v-if="this.active === 2">
        <van-cell class="card" v-for="(item, index) in list" :key="index">
          <van-tag v-if="item.Status === 20" class="info_tag" type="warning"
            >已结束</van-tag
          >
          <div class="warn_item">
            <div @click="goDetail(item)">
              <van-row>
                <van-col span="24">
                  {{ index + 1 }}、{{ item.CheckTaskName }}</van-col
                >
              </van-row>
              <van-row gutter="20" class="dep_sort">
                <van-col span="15">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                    alt=""
                  />{{ item.CheckTypeName +(item.ItemTypeName?'('+item.ItemTypeName+')':'') }}</van-col
                >
                <van-col span="9">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_danger.png"
                    alt=""
                  />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                    item.CheckCnt
                  }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />{{ item.CreateChnName }}</van-col
                >
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />{{ item.StartDate | formatDate }}至{{
                    item.EndDate | formatDate
                  }}</van-col
                >
              </van-row>
            </div>
          </div>
        </van-cell>
      </div>
    </page-tab-list>
  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";
import PageTabList from "@/components/PageTabList/PageTabList.vue";
export default {
  components: { PageTabList },
  data() {
    return {
      active: 0,
      list: [],
      params: [
        {
          title: "进行中的任务",
          dataType: "NotFinish",
        },
        {
          title: "未开始的任务",
          dataType: "NotStart",
        },
        {
          title: "已结束的任务",
          dataType: "Finished",
        },
      ],
    };
  },
  // created() {
  //   this.getList();
  //   this.getMyList();
  //   this.getFinishList();
  // },
  filters: {
    formatDate: function (value, args) {
      return getDateTime(value);
    },
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    goDetail(item) {
      this.$router.push({
        path: "/SytechDanger/DangerCheckTaskEdit",
        query: { id: item.ID },
      });
    },
    goFinishDetail(item) {
      this.$router.push({
        path: "/SytechDanger/DangerCheckTaskView",
        query: { id: item.ID },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.all_dep {
  background-color: #ffffff;
}

.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
